#!/usr/bin/python2.4

import opie
import cgi
import cookielib

print 'Content-type: text/html\n\n'
print
print

id = cgi.FieldStorage().getvalue('id')
p = cgi.FieldStorage().getvalue('password')
o = opie.user_manager()
o2 = o.create_db('localhost', 'dog2dog_corevet', 'edb73a*', 'dog2dog_corevet')
o.db = o.db.cursor()
#print dir(o)
ab = o.get_user(id, p, p)
print '<b>userid# '+id
ab.login('john', 'john')
print '<b>welcome '+ab.username
#print dir(o)
#print dir(ab)
print '<h4><a href="news.py?id='+id+'&password='+p+'">news subscriptions</a>'
print '<h4><a href="groups.py?id='+id+'&password='+p+'">groups</a>'
print '<h4><a href="contact.py">contact</a>'
#dd = o.get_all_users()
#print dd.rasta
#print dict(dd)
#dd.func()

#print dd.get_HTML()
print '<head><script type="text/javascript">'
#a='''
print '''
	function loadXMLDoc()
{
var xmlhttp;
if (window.XMLHttpRequest){ xmlhttp = new XMLHttpRequest();}
else{
	xmlhttp=newActiveXObject("Microsoft.XMLHTTP");
}
document.getElementById("mydiv1").innerHTML="<p><input type=text>";
}

function run(i){
	loadXMLDoc(i);

}

function alert_sys(){

	alert('123');
	entiredoc = document.documentElement;
	alert(entiredoc.nodeName);
	var elements = entiredoc.getElementsByTagName("tr");
	//for (int i=0;i<elements.length; i++) alert(elements[i].tagName)

}

</script></head>
'''
#print '<form action="home.py">'
#print '<p>id: <input type="text" name="id">'
#print '<p>password: <input type="password" name="password">'
#print '<p><input type="submit"></form>'
#'''
#y=0
#print '<table><th>obj_id</th><th>name</th><th>created</th><th>modified</th>'
#for z in dd:
#	print '<tr><td onclick=alert_sys()>'+str(z[0])+'</td><td>'+z[1].username+'</td><td>'+z[2]+'</td><td>'+z[3]+'</td><td><input type="button" value="click" onClick="alert_sys()"</td></tr>'
#print '</table>'
#	for x in dir(z):
#		a = str(eval('dd.'+x))
#		print '<div id="mydiv'+str(y)+'"><h5>click to edit</h5><p><br>'+x+': '+a+'</div><button type="button" onClick="loadXMLdoc()">edit</button>'
#	y = y+1
print '</body></html>'
